package com.atguigu.gmall.cart.config;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;

import java.util.concurrent.Executor;

@Configuration
public class AsyncConfig implements AsyncConfigurer {
//    @Override  给异步任务提供自定义线程池
//    public Executor getAsyncExecutor() {
//        return null;
//    }
    @Autowired
    AsyncExceptionHandler asyncExceptionHandler;
    //给异步任务提供异常处理器，出现异常时有该处理器处理
    @Override
    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
        return asyncExceptionHandler;
    }
}
